﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ScrumProject.Models
{
    public class WorkMeasyrementRepository : IDisposable
    {
        SMRPO6Context db = new SMRPO6Context();

       
        public IQueryable<WorkMeasurement> GetAllMeasurements()
        {
            return db.WorkMeasurements;
        }

        public WorkMeasurement GetMeasurementByUser(int id)
        {
            return (from wm in db.WorkMeasurements
                    where wm.userId == id
                   select wm).FirstOrDefault();
        }

         public void Save()
        {
            db.SaveChanges();
        }

        private bool disposed = false;

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    db.Dispose();
                }
            }
            this.disposed = true;
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}